package com.fyt.service.impl;

import com.fyt.service.buildService;
import com.fyt.utils.*;
import org.joor.Reflect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.*;
import java.util.Arrays;
import java.util.Date;
import java.util.Scanner;
import java.util.UUID;
import java.util.function.Supplier;

@Service
public class buildServiceImpl implements buildService {

    public ExecuteCodeResponse ExecuteJAVA(String code,String input) {
        if(input==null) input="";
        ExecuteCodeRequest executeCodeRequest = ExecuteCodeRequest.builder()
                .code(code)
                .language(QuestionSubmitLanguageEnum.JAVA)
                .inputList(Arrays.asList(input))
                .build();
        ExecuteCodeResponse executeCodeResponse = RemoteCodeSandbox.executeCode(executeCodeRequest);
        System.out.println(executeCodeResponse);
        return executeCodeResponse;
    }

    public ExecuteCodeResponse ExecuteCPP(String code,String input) {
        if(input==null) input="";
        ExecuteCodeRequest executeCodeRequest = ExecuteCodeRequest.builder()
                .code(code)
                .language(QuestionSubmitLanguageEnum.CPP)
                .inputList(Arrays.asList(input))
                .build();
        ExecuteCodeResponse executeCodeResponse = RemoteCodeSandbox.executeCode(executeCodeRequest);
        System.out.println(executeCodeResponse);
        return executeCodeResponse;
    }
}
